import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class CoreAppletVersionService extends BaseService<any> {
  private readonly logger = new Logger(CoreAppletVersionService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getPage
   * 对应 PHP: CoreAppletVersionService_core::getPage()
   * 逻辑类型: undefined - undefined
   */
  async getPage(where: any[]) {
    // 基于PHP真实逻辑: getPage
    // PHP原文: $field = 'id, site_id, type, uid, version, version_num, path, create_time, update_time,desc, config';         $search_model = $this->model->where($whe...
const field = 'id, site_id, type, uid, version, version_num, path, create_time, update_time,desc, config';
        const search_model = this.model.where(where).field(field).order('create_time desc'];
        return this.pageQuery(search_model);
    }

    /**
     * 获取版本信息
     * @param int id
     * @return */
    async getInfo(int id)
    {
        const field = 'id, site_id, type, uid, version, version_num, path, create_time, update_time,desc, config';
        return this.model.where([[ 'id', '=', id ))).field(field).findOrEmpty().toArray(];
    }


    /**
     * 通过版本号查询版本内容
     * @param string version
     * @param string type
     * @return */
    async getInfoByVersion(string version, string type){
        return this.model.where([['version', '=', version], ['type', '=', type))).findOrEmpty().toArray(;
  }
  }

  /**
   * getInfo
   * 对应 PHP: CoreAppletVersionService_core::getInfo()
   * 逻辑类型: undefined - undefined
   */
  async getInfo(id: number) {
    // 基于PHP真实逻辑: getInfo
    // PHP原文: $field = 'id, site_id, type, uid, version, version_num, path, create_time, update_time,desc, config';         return $this->model->where([[ 'id', '=',...
const field = 'id, site_id, type, uid, version, version_num, path, create_time, update_time,desc, config';
        return this.model.where([[ 'id', '=', id ))).field(field).findOrEmpty().toArray(];
    }


    /**
     * 通过版本号查询版本内容
     * @param string version
     * @param string type
     * @return */
    async getInfoByVersion(string version, string type){
        return this.model.where([['version', '=', version], ['type', '=', type))).findOrEmpty().toArray(;
  }
  }

  /**
   * getInfoByVersion
   * 对应 PHP: CoreAppletVersionService_core::getInfoByVersion()
   * 逻辑类型: undefined - undefined
   */
  async getInfoByVersion(version: string, type: string) {
    // 基于PHP真实逻辑: getInfoByVersion
    // PHP原文: return $this->model->where([['version', '=', $version], ['type', '=', $type]])->findOrEmpty()->toArray();     }    }...
return this.model.where([['version', '=', version], ['type', '=', type))).findOrEmpty().toArray(;
  }
  }
}
